home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 February / EnterCD 02_2004.iso / Gry / Arcade! Classic Arcade Pack 2.0 / Arcade.EXE / $PROGRAMFILES / Arcade! Classic Arcade Pack / snake.swf / scripts / frame_44 / DoAction.as
Encoding:
Text File  |  2003-12-05  |  3.7 KB  |  159 lines

  1. stop();
  2. showScores = function()
  3. {
  4.    var i = 5;
  5.    while(i > 0)
  6.    {
  7.       var n = scoreboard_lv["name" + (page + i)];
  8.       var s = scoreboard_lv["score" + (page + i)];
  9.       var l_mc = this["line" + i + "_mc"];
  10.       var lbg_mc = this["line" + i + "bg_mc"];
  11.       l_mc.rank_txt.text = lbg_mc.rank_txt.text = page + i + ".";
  12.       l_mc.name_txt.text = lbg_mc.name_txt.text = !n.length ? "-" : n.toUpperCase();
  13.       l_mc.score_txt.text = lbg_mc.score_txt.text = !s.length ? "-" : s;
  14.       l_mc._visible = lbg_mc._visible = true;
  15.       loading_mc._visible = false;
  16.       i--;
  17.    }
  18. };
  19. loadScores = function(num)
  20. {
  21.    next_btn._visible = back_btn._visible = slug_btn.enabled = worm_btn.enabled = python_btn.enabled = false;
  22.    slug_mc._alpha = worm_mc._alpha = python_mc._alpha = 40;
  23.    switch(num)
  24.    {
  25.       case 2:
  26.          slug_mc._alpha = 100;
  27.          break;
  28.       case 1:
  29.          worm_mc._alpha = 100;
  30.          break;
  31.       default:
  32.          python_mc._alpha = 100;
  33.    }
  34.    var i = 5;
  35.    while(i > 0)
  36.    {
  37.       this["line" + i + "_mc"]._visible = this["line" + i + "bg_mc"]._visible = false;
  38.       i--;
  39.    }
  40.    loading_mc.gotoAndStop(1);
  41.    loading_mc._visible = true;
  42.    page = 0;
  43.    maxScore = 100;
  44.    scoreboard_lv = new LoadVars();
  45.    if(score > 0 && game_so.data.playerName.length > 0)
  46.    {
  47.       scoreboard_lv.score = score;
  48.       scoreboard_lv.name = game_so.data.playerName.toLowerCase();
  49.    }
  50.    scoreboard_lv.game = "snake" + (3 - num);
  51.    scoreboard_lv.sendAndLoad("http://score.openwares.org/games_score_text.php",scoreboard_lv,"POST");
  52.    scoreboard_lv.onLoad = function(success)
  53.    {
  54.       if(success)
  55.       {
  56.          if(Boolean(scoreboard_lv.success))
  57.          {
  58.             next_btn._visible = true;
  59.             if(scoreboard_lv.maxScore.length > 0)
  60.             {
  61.                maxScore = Number(scoreboard_lv.maxScore);
  62.             }
  63.             showScores();
  64.          }
  65.          else
  66.          {
  67.             loading_mc.errorMsg = scoreboard_lv.errorMsg.toUpperCase();
  68.             loading_mc.gotoAndStop(2);
  69.          }
  70.       }
  71.       else
  72.       {
  73.          loading_mc.errorMsg = "COULD NOT ACCESS SCORES.";
  74.          loading_mc.gotoAndStop(2);
  75.       }
  76.       switch(num)
  77.       {
  78.          case 2:
  79.             worm_btn.enabled = python_btn.enabled = true;
  80.             break;
  81.          case 1:
  82.             slug_btn.enabled = python_btn.enabled = true;
  83.             break;
  84.          default:
  85.             slug_btn.enabled = worm_btn.enabled = true;
  86.       }
  87.    };
  88.    score = 0;
  89. };
  90. back_btn.onPress = function()
  91. {
  92.    page -= 5;
  93.    if(page < 0)
  94.    {
  95.       page = 0;
  96.    }
  97.    if(page < 5)
  98.    {
  99.       back_btn._visible = false;
  100.    }
  101.    next_btn._visible = true;
  102.    showScores();
  103. };
  104. next_btn.onPress = function()
  105. {
  106.    page += 5;
  107.    if(page > maxScore)
  108.    {
  109.       page = maxScore;
  110.    }
  111.    if(page > maxScore - 10)
  112.    {
  113.       next_btn._visible = false;
  114.    }
  115.    back_btn._visible = true;
  116.    showScores();
  117. };
  118. newGame_btn.onRelease = function()
  119. {
  120.    gotoAndStop(2);
  121. };
  122. slug_btn.onRollOver = function()
  123. {
  124.    slug_mc._alpha = 100;
  125. };
  126. slug_btn.onRollOut = slug_btn.onDragOut = function()
  127. {
  128.    slug_mc._alpha = 40;
  129. };
  130. slug_btn.onRelease = function()
  131. {
  132.    loadScores(2);
  133. };
  134. worm_btn.onRollOver = function()
  135. {
  136.    worm_mc._alpha = 100;
  137. };
  138. worm_btn.onRollOut = worm_btn.onDragOut = function()
  139. {
  140.    worm_mc._alpha = 40;
  141. };
  142. worm_btn.onRelease = function()
  143. {
  144.    loadScores(1);
  145. };
  146. python_btn.onRollOver = function()
  147. {
  148.    python_mc._alpha = 100;
  149. };
  150. python_btn.onRollOut = python_btn.onDragOut = function()
  151. {
  152.    python_mc._alpha = 40;
  153. };
  154. python_btn.onRelease = function()
  155. {
  156.    loadScores(0);
  157. };
  158. loadScores(level);
  159.